{extend name="public:edit" /}

<!-- 搜索栏 -->
{block name="content"}

    <div class="layui-form-item">
        <label class="layui-form-label">根目录</label>
        <div class="layui-input-block">
            <select name="admin_file_p_id">
                <option value="0">根目录</option>
                {if $info}
                    {foreach $info as $k => $v}
                        <option value="{$v['id']}">{$v['admin_file_p_title']}</option>
                    {/foreach}
                {/if}

            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="admin_file_p_title" value="" lay-verify="required" placeholder="点此请输入" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">上传文件</label>
        <div class="layui-input-block">
            <div class="layui-upload">
            <button type="button" class="layui-btn" id="test-upload-normal">上传图片</button>
            <input type="hidden" name="pic" value="" autocomplete="off" class="layui-input">
            <input type="hidden" name="pictype" value="" autocomplete="off" class="layui-input">
            <div class="layui-upload-list">
                <img class="layui-upload-img" style="width: 100px;" id="test-upload-normal-s" src="" alt="">
            </div>
            </div>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">图片压缩比例</label>
        <div class="layui-input-block">
            <div id="slideTest1">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">文件|目录</label>
        <div class="layui-input-block">
            <input type="radio" name="admin_file_file" value="1" title="文件" checked>
            <input type="radio" name="admin_file_file" value="0" title="目录">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">
            <input type="radio" name="admin_file_is_show" value="1" title="展示" checked>
            <input type="radio" name="admin_file_is_show" value="0" title="隐藏">
        </div>
    </div>

    <input type="hidden" name="zoom" value="10" autocomplete="off" class="layui-input">

{/block}

<!-- js 执行方法 -->
{block name="script"}
<script>
    layui.use('slider', function(){
        var slider = layui.slider;
        var $ = layui.$;
        
        //渲染
        slider.render({
            elem: '#slideTest1'  //绑定元素
            ,step: 10 //步长
            ,showstep: true //开启间隔点
            ,value:10
            ,change: function(value){
                //do something
                $('input[name="zoom"]').val(value)
            }
        });
    });
    views.verify(false).func(function(form,admin,upload,laydate){
        upload.render({
            elem: '#test-upload-normal'
            ,url: '/api/upload/'
            ,auto: false //选择文件后不自动上传
            ,bindAction: '' //指向一个按钮触发上传
            ,size:'1024'
            ,choose: function(obj){
                //将每次选择的文件追加到文件队列
                var files = obj.pushFile();
                
                //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                obj.preview(function(index, file, result){
                    // console.log(index); //得到文件索引
                    layui.$('#test-upload-normal-s').attr('src',result);
                    layui.$('input[name="pic"]').val(result)
                    layui.$('input[name="pictype"]').val(file.name)
                });
            }
        });      
    }).get();
</script>
{/block}
  
  